import unittest
from pygo1963.goLogic.GoUtils import get_opponent_color, get_vertex_around_position
from pygo1963.model.Constants import WHITE_COLOR, BLACK_COLOR
from pygo1963.model.Board import Board
from pygo1963.model.Vertex import Vertex

class GoUtilsTest(unittest.TestCase):

    def test_get_opponent_color(self):
        
        self.assertEqual(get_opponent_color(WHITE_COLOR), BLACK_COLOR)
        self.assertEqual(get_opponent_color(BLACK_COLOR), WHITE_COLOR)
    
    def test_get_squares_around_position(self):
        
        board = Board(9)
        
        squares = get_vertex_around_position(board.size, Vertex(0,0))
        
        self.assertEqual(len(squares), 2)
        
        squares = get_vertex_around_position(board.size, Vertex(8,0))
        
        self.assertEqual(len(squares), 2)
        
        squares = get_vertex_around_position(board.size, Vertex(7,3))
        
        self.assertEqual(len(squares), 4)
        
        squares = get_vertex_around_position(board.size, Vertex(8,4))
        
        self.assertEqual(len(squares), 3)

if __name__ == "__main__":
    unittest.main()